﻿using Microsoft.Office.Interop.Excel;
using Microsoft.Win32;
using MiniExcelLibs;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using PanhuaWin.工厂;
using PanhuaWin.系统管理;
using PanhuaWin.通用;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using System.Windows.Forms;
using DataTable = System.Data.DataTable;

namespace PanhuaWin.车间.镀锌
{
    public partial class Form镀锌报工维护 : UIPage

    {


        string FormGuid;
        int 开始行;
        int 结束行;
        string form部门编号;
        string form部门名称;
        string form产线名称;
        string form仓库名称;
        string tempguid;
        string 镀锌原卷guid;
        string FormWorkType = "镀锌";
        decimal 卷的总重量;
        string 用来保存的原卷号;

        public string 投入卷规格型号 { get; private set; }
        public string 投入卷厚度;
        public string 投入卷宽度;
        public string 投入卷材质;
        public string 投入卷重量;
        public string 投入卷规格;
        public string 投入卷产品规格;
        public string 投入卷客户;
        public string 投入卷去向;

        public Form镀锌报工维护()
        {
            InitializeComponent();
        }

        private void uiButton选择卷_Click(object sender, EventArgs e)
        {

        }

        private void uiLabel2_Click(object sender, EventArgs e)
        {

        }

        private void Form镀锌报工维护_Resize(object sender, EventArgs e)
        {


        }

        private void Form镀锌报工维护_Load(object sender, EventArgs e)
        {
            tempguid = Guid.NewGuid().ToString();
            this.uiDatePicker报工日期.Value = pub.刷新时间();
            this.uiDatePicker开始日期.Value = DateTime.Today;
            this.uiDatePicker结束日期.Value = DateTime.Today;
            this.uiTextBox工厂名称.Text = pub.全局工厂名称;
            pub.ListMaterial(pub.全局工厂编号, FormWorkType, this.uiComboBox新材质);
            //pub.ListMaterial(pub.全局工厂编号, FormWorkType, this.uiComboBox查询材质);
            pub.ListRank(pub.全局工厂编号, this.uiComboBox质量等级);
            pub.ListWorkLine(pub.全局工厂编号, FormWorkType, this.uiComboBox产线);
            pub.ListWorkType(pub.全局工厂编号, FormWorkType, this.uiComboBox去向);
            //pub.ListRank(pub.全局工厂编号, this.uiComboBox质量等级);
            pub.ListDayShift(pub.全局工厂编号, this.uiComboBoxDayShift);
            pub.ListWorkLineAll(pub.全局工厂编号, FormWorkType, this.uiComboBox查询产线);
            pub.ListQualityStandard(FormWorkType, this.uiComboBox执行标准);
            pub.ListFaceDone(FormWorkType, this.uiComboBox表面处理);
            pub.ListWareHouse(this.uiComboBox仓库, pub.全局工厂guid);
            pub.ListQualityInfo(pub.全局工厂编号, FormWorkType, uiComboBox质量信息);
            this.uiComboBox仓库.SelectedValue = "FD1";
            清理自己mac的Temp_镀锌报工原卷占用();
            pub.ListWorkTeamAll(pub.全局工厂编号, this.uiComboBox产线.SelectedValue.ToString(), this.uiComboBox查询班组);

            string 当前班组 = pub.Get员工所属班组(pub.sys_user.UserTrueName);
            if (当前班组 == "")
            {
                pub.ListWorkTeam(pub.全局工厂编号, this.uiComboBox产线.SelectedValue.ToString(), this.uiComboBoxWorkTeam);
            }
            else
            {
                this.uiComboBoxWorkTeam.Items.Add(当前班组);
                this.uiComboBoxWorkTeam.SelectedIndex = 0;
                this.uiComboBox查询班组.SelectedValue = 当前班组;
            }
            uiComboBox包装.Items.Add("精包");
            uiComboBox包装.Items.Add("简包");
            uiComboBox包装.Items.Add("普包");
            uiComboBox包装.Items.Add("裸包");
            uiComboBox包装.Items.Add("无");
            uiComboBox包装.SelectedIndex = 2;
        }

       

        private void 清理自己mac的Temp_镀锌报工原卷占用()
        {
            string sql;
            sql = "delete Temp_镀锌报工原卷占用 where mac='" + pub.getMac() + "' ";
            pub.ExecuteSql(pub.ConnectionString, sql, "清理自己mac的Temp_镀锌报工原卷占用,Temp_镀锌报工原卷占用");
        }

        private void uiLabel31_Click(object sender, EventArgs e)
        {

        }

        private void uiLabel33_Click(object sender, EventArgs e)
        {

        }

        private void uiButton选择已发未完工_Click(object sender, EventArgs e)
        {
            
            Form已酸洗轧硬未镀锌 form已酸洗轧硬未镀锌 = new Form已酸洗轧硬未镀锌();
            form已酸洗轧硬未镀锌.工厂编号 = pub.全局工厂编号;
            删除自己的tempguid的数据(tempguid);  //Temp_镀锌报工原卷占用
            if (form已酸洗轧硬未镀锌.ShowDialog(this) == DialogResult.OK)
            {
                this.uiTextBox原料卷号.Text = form已酸洗轧硬未镀锌.卷信息.OutputVolumeNew;
                镀锌原卷guid = pub.Get镀锌报工guid(this.uiTextBox原料卷号.Text);
                if (镀锌原卷guid == "")
                {
                    MessageBox.Show("投入卷号选择有问题，请联系一下系统管理员处理: " + this.uiTextBox原料卷号.Text, "提示", MessageBoxButtons.OK);
                    return;
                }
                this.uiTextBox产出卷号.Text = pub.去掉前缀(this.uiTextBox原料卷号.Text);//不含前缀，不含后面的串号
                                                                            //this.uiTextBox存货编号1.Text = form已酸洗未完工.卷信息.InventoryCode;
                                                                            //this.uiTextBox存货名称1.Text = form已酸洗未完工.卷信息.InventoryName;


                //uiTextBox规格型号1.Text

                投入卷规格型号 = pub.Get卷计划产品规格(this.uiTextBox原料卷号.Text);
                string 虚拟值;
                pub.FromSize(投入卷规格型号, out 投入卷厚度, out 投入卷宽度, out 虚拟值);


                //this.uiTextBox米数.Text = form已酸洗轧硬未镀锌.卷信息.OutputMeter.ToString();
                // this.uiTextBox新厚度.Text = pub.Get镀锌厚度(厚度);
                //this.uiTextBox新宽度.Text = 宽度;
                //this.uiTextBox产地1.Text = form已酸洗轧硬未镀锌.卷信息.OutputAddress;
                //this.uiTextBox卷重量1.Text = form已酸洗轧硬未镀锌.卷信息.OutputWeight.ToString();
                this.uiTextBox新重量.Text = "";
                //uiTextBox新米数.Text = this.uiTextBox米数.Text;
                //this.uiTextBox材质1.Text = form已酸洗轧硬未镀锌.卷信息.OutputMaterial;
                //this.uiComboBox新材质.Text = this.uiTextBox材质1.Text;
                //this.uiTextBox计量单位1.Text = "Kg";
                // this.uiComboBox去向.SelectedValue = form已酸洗未完工.卷信息.OutputNext;

                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));

                塞入自己的tempguid的数据(tempguid, form已酸洗轧硬未镀锌.卷信息.VolumeCodeNew);
            }
            else
            {
                镀锌原卷guid = "";
                删除自己的tempguid的数据(tempguid);  //Temp_镀锌报工原卷占用
            }



        }

        private void 塞入自己的tempguid的数据(string tempguid, string volumeCodeNew)
        {
            string sql;
            sql = "insert into Temp_镀锌报工原卷占用(guid, OriginalVolumeNew, MAC, 时间 ) values('" + tempguid + "','" + volumeCodeNew + "','" + pub.getMac() + "' ,getdate()) ";
            pub.ExecuteSql(pub.ConnectionString, sql, "删除自己的tempguid的数据,Temp_镀锌报工原卷占用");
        }

        private void 删除自己的tempguid的数据(string tempguid)
        {
            string sql;
            //sql = "delete Temp_镀锌报工原卷占用 where guid='" + tempguid + "' ";
            sql = "delete Temp_镀锌报工原卷占用 where mac='" + pub.getMac() + "' ";
            pub.ExecuteSql(pub.ConnectionString, sql, "删除自己的tempguid的数据,Temp_镀锌报工原卷占用");
        }


        private void CleallAll()
        {
            this.uiDataGridView产出.DataSource = null;
            this.uiDataGridView产出.Refresh();
            /*
            this.uiTextBox产地1.Text = "";
            this.uiCheckBox拆成多卷.Checked = false;
            this.numericUpDown1.Value = 1;
            uiTextBox原料卷号.Text = "";
            this.uiTextBox产出卷号.Text = "";
            镀锌原卷guid = "";
            删除自己的tempguid的数据(tempguid);

            this.uiTextBox存货编号1.Text = "";
            this.uiTextBox存货名称1.Text = "";
            this.uiTextBox轧制规格.Text = "";
            this.uiTextBox成品规格.Text = "";
            this.uiTextBox备注1.Text = "";
            uiTextBox规格型号1.Text = "";
            string 厚度 = "";
            string 宽度 = "";
            string 虚拟值 = "";

            this.uiTextBox厚度1.Text = 厚度;
            this.uiTextBox宽度1.Text = 宽度;
            this.uiTextBox虚拟值1.Text = 虚拟值;
            this.uiTextBox新厚度.Text = 厚度;
            this.uiTextBox新宽度.Text = 宽度;
            this.uiTextBox产地1.Text = "";
            this.uiTextBox卷重量1.Text = "";
            this.uiTextBox材质1.Text = "";
            //this.uiComboBox新材质.Text = "";
            this.uiTextBox计量单位1.Text = "Kg";
            //this.uiComboBox去向.SelectedValue = form已发未完工卷.出库卷信息.NextWorkType;
            this.uiTextBox计划去向.Text = "";
             
            uiTextBox新重量.Text = "";
            uiTextBox新规格.Text = "";
            uiTextBox新重量.Text = "";
            uiTextBox轧制规格.Text = "";
            */
            tempguid = Guid.NewGuid().ToString();
            清理自己mac的Temp_镀锌报工原卷占用();

        }







        private void uiComboBox产线_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (this.uiComboBox产线.SelectedValue.ToString() != "")
            {
                // pub.ListWorkType(pub.全局工厂编号, FormWorkType, this.uiComboBox去向);
                Dic_Depart dic_Depart = pub.GetDepartByWorkLine(this.uiComboBox产线.SelectedText);
                if (dic_Depart != null)
                {
                    form部门名称 = dic_Depart.DepartName;
                    form部门编号 = dic_Depart.DepartCode;
                }
                else
                {
                    form部门名称 = "";
                    form部门编号 = "";
                }
                this.uiComboBox仓库.SelectedValue = pub.根据产线获得仓库编号(this.uiComboBox产线.SelectedText);

            }
        }

        private void uiTextBox新厚度_TextChanged(object sender, EventArgs e)
        {
            SetSize();
            刷新理算米数();
        }

        private void 刷新理算米数()
        {
            double 手填重量;

            手填重量 = pub.Todouble(this.uiTextBox新重量.Text);
            double 手填宽度;
            手填宽度 = pub.Todouble(this.uiTextBox新宽度.Text);
            double 手填厚度;
            手填厚度 = pub.Todouble(this.uiTextBox新厚度.Text);
            //decimal 手填米数;
            //手填米数 = pub.Todecimal(this.uiTextBox新米数.Text);
            if (手填重量 > 0 && 手填宽度 > 0 && 手填厚度 > 0)
            {
                this.uiTextBox理算米数.Text = Math.Round((手填重量 / (手填宽度 / 1000) / 手填厚度 / 7.85), 4).ToString();
            }
            else
            {
                this.uiTextBox理算米数.Text = "";
            }
        }

        private void uiTextBox新宽度_TextChanged(object sender, EventArgs e)
        {
            SetSize();
            刷新理算米数();
            刷新理算厚度();
        }
        private void SetSize()
        {
            this.uiTextBox新规格.Text = pub.Todecimal(this.uiTextBox新厚度.Text, 3) + "*" + pub.ToInt(this.uiTextBox新宽度.Text) + "*C";
            //this.uiTextBox新规格.Text = pub.Todecimal(this.uiTextBox新厚度.Text, 3) + "*" + pub.ToInt(this.uiTextBox成品宽度.Text) + "*C";
        }

        private void uiCheckBox拆成多卷_CheckedChanged(object sender, EventArgs e)
        {
            if (this.uiCheckBox拆成多卷.Checked)
            {
                this.numericUpDown1.Visible = true;
            }
            else
            {
                this.numericUpDown1.Visible = false;
            }
        }

        private void uiButton添加产出卷_Click(object sender, EventArgs e)
        {

            this.uiTextBox原料卷号.Text = 用来保存的原卷号;
            if (pub.Todecimal(this.uiTextBox卷重量1.Text) * pub.Todecimal(1.1) < 卷的总重量 + pub.Todecimal(this.uiTextBox新重量.Text))
            {
                MessageBox.Show("产出卷的重量超过了投入卷重量,不能单卷报工。", "提示", MessageBoxButtons.OK);
                return;
            }
            if (this.uiComboBox质量等级.SelectedText == "全部")
            {
                MessageBox.Show("质量等级不能是全部。请选择具体的质量等级。", "提示", MessageBoxButtons.OK);
                return;
            }
            if (!pub.IsRightSize(this.uiTextBox新规格.Text))
            {
                MessageBox.Show("规格有问题，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            if (string.IsNullOrWhiteSpace(uiComboBox新材质.Text.Trim()))
            {
                MessageBox.Show("请选择或输入材质", "提示", MessageBoxButtons.OK);
                return;
            }

            if (this.uiComboBox质量等级.SelectedText == "B" && this.uiComboBox质量等级.SelectedText == "下线入库")
            {
                if (this.uiComboBox品名.SelectedText.Substring(0, 1) == "B")
                {

                }
                else
                {
                    MessageBox.Show("下线入库的产品等级B时，产品必须是B级品", "提示", MessageBoxButtons.OK);
                    return;
                }
            }
            if (this.uiComboBox质量等级.SelectedText != "B" && this.uiComboBox质量等级.SelectedText == "下线入库")
            {
                if (this.uiComboBox品名.SelectedText.Substring(0, 1) == "B")
                {
                    MessageBox.Show("下线入库的产品等级不是B时，产品必须不是B级品", "提示", MessageBoxButtons.OK);
                    return;
                }
            }

            if (this.uiCheckBox拆成多卷.Checked == false)
            {
                //单卷
                //已经存在的就不能再次点击添加了
                if (!pub.Is镀锌报工原始卷被关闭(this.uiTextBox原料卷号.Text))
                {
                    string sql;
                    List<Bus_ZincOutput> bus_zincoutputs = pub.Get镀锌产出卷信息All(this.uiTextBox原料卷号.Text);
                    if (bus_zincoutputs != null)
                    {
                        MessageBox.Show("这个卷已经有产出卷了,不能单卷报工。", "提示", MessageBoxButtons.OK);
                        return;
                    }
                    //if (MessageBox.Show("这卷不再分拆会自动关闭，是否确认?", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    //{
                    单卷报工();
                    //}
                }
                else
                {
                    MessageBox.Show("这个卷已经被关闭了，不能再次报工了，如需要再次报工，请联系管理员处理。", "提示", MessageBoxButtons.OK);
                    return;
                }

            }
            else
            {
                //单卷
                //已经存在的就不能再次点击添加了
                if (!pub.Is镀锌报工原始卷被关闭(this.uiTextBox原料卷号.Text))
                {
                    List<Bus_ZincOutput> bus_zincoutputs = pub.Get镀锌产出卷信息All(this.uiTextBox原料卷号.Text);
                    if (bus_zincoutputs != null)
                    {
                        bool s = false;
                        foreach (Bus_ZincOutput bus_zincoutput in bus_zincoutputs)
                        {
                            if (this.uiTextBox原料卷号.Text.Replace("PHY", "").Replace("PHS", "") == bus_zincoutput.OutputVolumeNew.Replace("PHD", ""))
                            {
                                s = true;
                            }
                        }
                        if (s)
                        {
                            MessageBox.Show("这个卷已经有产出单卷了,不能多卷报工。", "提示", MessageBoxButtons.OK);
                            return;
                        }

                    }
                    多卷报工();
                }
                else
                {
                    MessageBox.Show("这个卷已经被关闭了，不能再次报工了，如需要强制报工，请联系管理员处理。", "提示", MessageBoxButtons.OK);
                    return;
                }

            }
        }

        private void 多卷报工()
        {

            if (镀锌原卷guid == "" || this.uiTextBox原料卷号.Text == "")
            {
                MessageBox.Show("没有选择投入卷号", "提示", MessageBoxButtons.OK);
                return;
            }
            string sql;
            //在镀锌卷分卷时补0，比如01,02
            string 新卷号 = this.uiTextBox前缀.Text + this.uiTextBox产出卷号.Text + this.numericUpDown1.Value.ToString().PadLeft(2, '/');

            Bus_ZincOutput bus_zincoutput = new Bus_ZincOutput();
            bus_zincoutput.Creator = pub.sys_user.UserName;
            bus_zincoutput.OutputDate = this.uiDatePicker报工日期.Value;
            if (this.uiComboBox去向.SelectedText == "")
            {
                MessageBox.Show("去向不能为空", "提示", MessageBoxButtons.OK);
                return;

            }
            if (pub.Get镀锌产出卷信息(新卷号) != null)
            {
                MessageBox.Show("产出卷号已经存在了，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.OutputNext = this.uiComboBox去向.SelectedText;
            bus_zincoutput.WorkLineName = this.uiComboBox产线.SelectedText;
            if (bus_zincoutput.WorkLineName == "")
            {
                MessageBox.Show("产线为空，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.WorkLineCode = this.uiComboBox产线.SelectedValue.ToString();
            bus_zincoutput.DayShiftCode = this.uiComboBoxDayShift.SelectedValue.ToString();
            bus_zincoutput.DayShiftName = this.uiComboBoxDayShift.SelectedText;

            bus_zincoutput.WorkTeamCode = this.uiComboBoxWorkTeam.SelectedText;
            if (bus_zincoutput.WorkTeamCode == "")
            {
                MessageBox.Show("班组为空，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.WorkTeamName = this.uiComboBoxWorkTeam.SelectedText;

            //bus_zincoutput.DepartCode = this.uiTextBox部门1.Text;
            //bus_zincoutput.DepartName = this.uiTextBox部门名称1.Text;
            bus_zincoutput.guid = Guid.Parse(镀锌原卷guid);
            bus_zincoutput.OutputGuid = Guid.NewGuid();
            bus_zincoutput.OutputMaterial = this.uiComboBox新材质.Text;
            bus_zincoutput.OutputQualityGrade = this.uiComboBox质量等级.SelectedText;
            bus_zincoutput.OutputQualityInformation = this.uiComboBox质量信息.Text.Trim().Replace("--", "");
            pub.UpdateQualityInformation(pub.全局工厂编号, FormWorkType, bus_zincoutput.OutputQualityInformation);
            bus_zincoutput.OutputSize = this.uiTextBox新规格.Text;
            bus_zincoutput.OutputThick = pub.Todecimal(uiTextBox新厚度.Text);
            bus_zincoutput.OutputWidth = uiTextBox新宽度.Text;
            bus_zincoutput.ProductWidth = this.uiTextBox成品宽度.Text;
            bus_zincoutput.OutputWeight = pub.Todecimal(uiTextBox新重量.Text);
            if (bus_zincoutput.OutputWeight == 0)
            {
                MessageBox.Show("重量为0，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.OutputMeter = pub.Todecimal(uiTextBox新米数.Text);
            if (bus_zincoutput.OutputMeter == 0)
            {
                MessageBox.Show("米数为0，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.Customer = this.uiTextBox客户.Text;
            bus_zincoutput.OutputAddress = this.uiTextBox产地1.Text;

            if (this.uiComboBox品名.Visible == true)
            {
                bus_zincoutput.InventoryName = uiComboBox品名.SelectedText;
                bus_zincoutput.InventoryCode = pub.GetInventoryCode(bus_zincoutput.InventoryName, bus_zincoutput.OutputSize, bus_zincoutput.OutputMaterial);
                if (bus_zincoutput.InventoryCode == "")
                {
                    MessageBox.Show("这个卷没有对应的NC存货编号", "提示", MessageBoxButtons.OK);
                }
                bus_zincoutput.FaceDone = this.uiComboBox表面处理.SelectedText;
                bus_zincoutput.QualityStandard = this.uiComboBox执行标准.SelectedText;
            }
            else
            {
                bus_zincoutput.InventoryName = "";
                bus_zincoutput.InventoryCode = "";
                bus_zincoutput.FaceDone = "";
                bus_zincoutput.QualityStandard = "";
            }
            bus_zincoutput.ZincThick = this.uiTextBox锌层.Text.Trim().Replace("--", "");
            ///验证理算厚度
            if (!pub.符合理算厚度(pub.Todecimal(this.uiTextBox新厚度.Text), pub.Todecimal(this.uiTextBox理算厚度.Text)))
            {
                if (MessageBox.Show("这个卷的理算厚度和成品厚度有问题，是否需要添加？", "询问", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }

            }
            sql = " insert into Bus_ZincOutput(OutputGuid, outputdate,guid, VolumeCodeNew,Row, OutputVolumeNew, OutputSize, OutputThick, OutputWidth, OutputMaterial, OutputWeight, OutputMeter,";
            sql += " OutputQualityGrade, OutputQualityInformation, OutputEndStatus, OutputNext, PrintTimes, DepartCode, DepartName, ";
            sql += " WorkLineCode, WorkLineName, WorkTeamCode, WorkTeamName, DayShiftCode, DayShiftName, CreateID, Creator,";
            sql += " CreateDate,OutputAddress,InventoryCode, InventoryName, FaceDone,QualityStandard,Customer,ProductWidth,ZincThick,LisuanThick,LisuanMeter,Package,Area,卷径)";
            sql += " values(newid(),'" + bus_zincoutput.OutputDate + "','" + 镀锌原卷guid + "','" + 用来保存的原卷号 + "','" + this.numericUpDown1.Value.ToString() + "','" + 新卷号 + "','" + bus_zincoutput.OutputSize + "','" + bus_zincoutput.OutputThick + "','" + bus_zincoutput.OutputWidth + "',";
            sql += " '" + bus_zincoutput.OutputMaterial + "','" + bus_zincoutput.OutputWeight + "','" + bus_zincoutput.OutputMeter + "','" + bus_zincoutput.OutputQualityGrade + "','" + bus_zincoutput.OutputQualityInformation + "',";
            sql += "  '','" + bus_zincoutput.OutputNext + "',0,'" + bus_zincoutput.DepartCode + "','" + bus_zincoutput.DepartName + "',";
            sql += " '" + bus_zincoutput.WorkLineCode + "','" + bus_zincoutput.WorkLineName + "','" + bus_zincoutput.WorkTeamCode + "','" + bus_zincoutput.WorkTeamName + "',";
            sql += " '" + bus_zincoutput.DayShiftCode + "','" + bus_zincoutput.DayShiftName + "','" + pub.sys_user.User_Id + "','" + pub.sys_user.UserTrueName + "',";
            sql += " getdate(),'" + bus_zincoutput.OutputAddress + "','" + bus_zincoutput.InventoryCode + "','" + bus_zincoutput.InventoryName + "',";
            sql += " '" + bus_zincoutput.FaceDone + "','" + bus_zincoutput.QualityStandard + "','" + bus_zincoutput.Customer + "','" + bus_zincoutput.ProductWidth + "','" + bus_zincoutput.ZincThick + "','" + uiTextBox理算厚度.Text + "','" + uiTextBox理算米数.Text + "','"+uiComboBox包装.SelectedText+ "','"+uiTextBox面积.Text.Trim()+"','"+uiTextBox卷径.Text.Trim()+"') ";

            if (pub.ExecuteSql(pub.ConnectionString, sql, "多卷镀锌报工塞入bus_zincoutput") > 0)
            {
                MessageBox.Show("多卷镀锌报工成功", "提示", MessageBoxButtons.OK);
                //不用自动关闭
                //sql = "update Bus_PicklingOriginal set IsClosed='Y' , ColseUserId='" + pub.sys_user.User_Id + "',ColseUserName='" + pub.sys_user.UserTrueName + "',CloseDate=getdate() where guid='" + 镀锌原卷guid + "'";
                //pub.ExecuteSql(pub.ConnectionString, sql, "单卷镀锌报工成功，自动关闭原卷的状态");
                //更新投入卷状态；
                if (this.uiTextBox原料卷号.Text.Contains("PHS"))
                {
                    sql = "update Bus_PicklingOutput set OutputEndStatus='已被镀锌' where OutputVolumeNew='" + this.uiTextBox原料卷号.Text + "'";
                    pub.ExecuteSql(pub.ConnectionString, sql, "镀锌报工改写酸洗产出卷状态");
                }
                else if (this.uiTextBox原料卷号.Text.Contains("PHY"))
                {
                    sql = "update Bus_HardOutput set OutputEndStatus='已被镀锌' where OutputVolumeNew='" + this.uiTextBox原料卷号.Text + "'";
                    pub.ExecuteSql(pub.ConnectionString, sql, "镀锌报工改写轧硬产出卷状态");
                }

                //显示卷信息到表格上
                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                this.numericUpDown1.Value = this.numericUpDown1.Value + 1;
                return;
            }
        }

        private void 单卷报工()
        {
            if (镀锌原卷guid == "" || this.uiTextBox原料卷号.Text == "")
            {
                MessageBox.Show("没有选择投入卷号", "提示", MessageBoxButtons.OK);
                return;
            }
            string sql;

            string 新卷号 = this.uiTextBox前缀.Text + this.uiTextBox产出卷号.Text;
            Bus_ZincOutput bus_zincoutput = new Bus_ZincOutput();
            bus_zincoutput.Creator = pub.sys_user.UserName;
            bus_zincoutput.OutputDate = this.uiDatePicker报工日期.Value;
            if (this.uiComboBox去向.SelectedText == "")
            {
                MessageBox.Show("去向不能为空", "提示", MessageBoxButtons.OK);
                return;

            }
            bus_zincoutput.OutputNext = this.uiComboBox去向.SelectedText;
            bus_zincoutput.WorkLineName = this.uiComboBox产线.SelectedText;
            if (bus_zincoutput.WorkLineName == "")
            {
                MessageBox.Show("产线为空，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.WorkLineCode = this.uiComboBox产线.SelectedValue.ToString();
            bus_zincoutput.DayShiftCode = this.uiComboBoxDayShift.SelectedValue.ToString();
            bus_zincoutput.DayShiftName = this.uiComboBoxDayShift.SelectedText;

            bus_zincoutput.WorkTeamCode = this.uiComboBoxWorkTeam.SelectedText;
            if (bus_zincoutput.WorkTeamCode == "")
            {
                MessageBox.Show("班组为空，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.WorkTeamName = this.uiComboBoxWorkTeam.SelectedText;

            //bus_zincoutput.DepartCode = this.uiTextBox部门1.Text;
            //bus_zincoutput.DepartName = this.uiTextBox部门名称1.Text;
            bus_zincoutput.guid = Guid.Parse(镀锌原卷guid);
            bus_zincoutput.OutputGuid = Guid.NewGuid();
            bus_zincoutput.OutputMaterial = this.uiComboBox新材质.Text;
            bus_zincoutput.OutputQualityGrade = this.uiComboBox质量等级.SelectedText;
            bus_zincoutput.OutputQualityInformation = this.uiComboBox质量信息.Text.Trim().Replace("--", "");
            pub.UpdateQualityInformation(pub.全局工厂编号, FormWorkType, bus_zincoutput.OutputQualityInformation);
            bus_zincoutput.OutputSize = this.uiTextBox新规格.Text;
            bus_zincoutput.OutputThick = pub.Todecimal(uiTextBox新厚度.Text);
            //厚度跟理算厚度
            bus_zincoutput.OutputWidth = uiTextBox新宽度.Text;
            bus_zincoutput.ProductWidth = this.uiTextBox成品宽度.Text;
            bus_zincoutput.OutputWeight = pub.Todecimal(uiTextBox新重量.Text);
            if (bus_zincoutput.OutputWeight == 0)
            {
                MessageBox.Show("重量为0，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.OutputMeter = pub.Todecimal(uiTextBox新米数.Text);
            if (bus_zincoutput.OutputMeter == 0)
            {
                MessageBox.Show("米数为0，不能添加", "提示", MessageBoxButtons.OK);
                return;
            }
            bus_zincoutput.Customer = this.uiTextBox客户.Text;
            bus_zincoutput.OutputAddress = this.uiTextBox产地1.Text;
            if (this.uiComboBox品名.Visible == true)
            {
                bus_zincoutput.InventoryName = uiComboBox品名.SelectedText;
                bus_zincoutput.InventoryCode = pub.GetInventoryCode(bus_zincoutput.InventoryName, bus_zincoutput.OutputSize, bus_zincoutput.OutputMaterial);
                if (bus_zincoutput.InventoryCode == "")
                {
                    //MessageBox.Show("这个卷没有对应的NC存货编号", "提示", MessageBoxButtons.OK);
                }
                bus_zincoutput.FaceDone = this.uiComboBox表面处理.SelectedText;
                bus_zincoutput.QualityStandard = this.uiComboBox执行标准.SelectedText;
            }
            else
            {
                bus_zincoutput.InventoryName = "";
                bus_zincoutput.InventoryCode = "";
                bus_zincoutput.FaceDone = "";
                bus_zincoutput.QualityStandard = "";
            }
            bus_zincoutput.ZincThick = this.uiTextBox锌层.Text.Trim().Replace("--", "");
            ///验证理算厚度
            if (!pub.符合理算厚度(pub.Todecimal(this.uiTextBox新厚度.Text), pub.Todecimal(this.uiTextBox理算厚度.Text)))
            {
                if (MessageBox.Show("这个卷的理算厚度和成品厚度有问题，是否需要添加？", "询问", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }

            }
            sql = " insert into Bus_ZincOutput(OutputGuid, outputdate,guid, VolumeCodeNew,Row, OutputVolumeNew, OutputSize, OutputThick, OutputWidth, OutputMaterial, OutputWeight, OutputMeter,";
            sql += " OutputQualityGrade, OutputQualityInformation, OutputEndStatus, OutputNext, PrintTimes, DepartCode, DepartName, ";
            sql += " WorkLineCode, WorkLineName, WorkTeamCode, WorkTeamName, DayShiftCode, DayShiftName, CreateID, Creator,";
            sql += " CreateDate,OutputAddress,InventoryCode, InventoryName, FaceDone,QualityStandard,Customer,ProductWidth,ZincThick,LisuanThick,LisuanMeter,Package ,Area,卷径)";
            sql += " values(newid(),'" + bus_zincoutput.OutputDate + "','" + 镀锌原卷guid + "','" + 用来保存的原卷号 + "','" + this.numericUpDown1.Value.ToString() + "','" + 新卷号 + "','" + bus_zincoutput.OutputSize + "','" + bus_zincoutput.OutputThick + "','" + bus_zincoutput.OutputWidth + "',";
            sql += " '" + bus_zincoutput.OutputMaterial + "','" + bus_zincoutput.OutputWeight + "','" + bus_zincoutput.OutputMeter + "','" + bus_zincoutput.OutputQualityGrade + "','" + bus_zincoutput.OutputQualityInformation + "',";
            sql += "  '','" + bus_zincoutput.OutputNext + "',0,'" + bus_zincoutput.DepartCode + "','" + bus_zincoutput.DepartName + "',";
            sql += " '" + bus_zincoutput.WorkLineCode + "','" + bus_zincoutput.WorkLineName + "','" + bus_zincoutput.WorkTeamCode + "','" + bus_zincoutput.WorkTeamName + "',";
            sql += " '" + bus_zincoutput.DayShiftCode + "','" + bus_zincoutput.DayShiftName + "','" + pub.sys_user.User_Id + "','" + pub.sys_user.UserTrueName + "',";
            sql += " getdate(),'" + bus_zincoutput.OutputAddress + "','" + bus_zincoutput.InventoryCode + "','" + bus_zincoutput.InventoryName + "',";
            sql += " '" + bus_zincoutput.FaceDone + "','" + bus_zincoutput.QualityStandard + "','" + bus_zincoutput.Customer + "','" + bus_zincoutput.ProductWidth + "','" + bus_zincoutput.ZincThick + "','" + uiTextBox理算厚度.Text + "','" + uiTextBox理算米数.Text + "','"+uiComboBox包装.SelectedText+ "','" + uiTextBox面积.Text.Trim() + "','"+uiTextBox卷径.Text.Trim()+"') ";
            if (pub.ExecuteSql(pub.ConnectionString, sql, "单卷镀锌报工塞入bus_zincoutput") > 0)
            {
                MessageBox.Show("单卷镀锌报工成功", "提示", MessageBoxButtons.OK);
                //sql = "update Bus_ZincOriginal set IsClosed='Y' , ColseUserId='" + pub.sys_user.User_Id + "',ColseUserName='" + pub.sys_user.UserTrueName + "',CloseDate=getdate() where guid='" + 镀锌原卷guid + "'";
                //pub.ExecuteSql(pub.ConnectionString, sql, "单卷镀锌报工成功，自动关闭原卷的状态");
                //显示卷信息到表格上
                if (this.uiTextBox原料卷号.Text.Contains("PHS"))
                {
                    sql = "update Bus_PicklingOutput set OutputEndStatus='已被镀锌' where OutputVolumeNew='" + this.uiTextBox原料卷号.Text + "'";
                    pub.ExecuteSql(pub.ConnectionString, sql, "镀锌报工改写酸洗产出卷状态");
                }
                else if (this.uiTextBox原料卷号.Text.Contains("PHY"))
                {
                    sql = "update Bus_HardOutput set OutputEndStatus='已被镀锌' where OutputVolumeNew='" + this.uiTextBox原料卷号.Text + "'";
                    pub.ExecuteSql(pub.ConnectionString, sql, "镀锌报工改写轧硬产出卷状态");
                }

                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                return;
            }


        }

        private void ListOutput(string 投入卷号)
        {
            卷的总重量 = 0;
            string 查询投入卷号1 = "PHS" + 投入卷号.Replace("PHS", "");  //酸洗
            string 查询投入卷号2 = "PHY" + 投入卷号.Replace("PHY", "");  //轧硬

            string 实际投入卷号 = "";
            string sql;
            sql = "SELECT   OutputGuid,VolumeCodeNew, OutputDate 报工日期,guid, Row, OutputVolumeNew 新卷号, OutputSize 新规格, OutputThick 新厚度, OutputWidth 新宽度, ";
            sql += " OutputMaterial 新材质, OutputWeight 新重量,OutputMeter 新米数,OutputQualityGrade 质量等级, OutputQualityInformation 质量信息, OutputEndStatus 后续状态,";
            sql += " OutputNext 去向,InventoryCode 存货编号,InventoryName 品名, FaceDone 表面处理, FaceStatus 表面状态,QualityStandard 执行标准,";
            sql += " PrintTimes 打印次数, DepartCode 部门编号, DepartName 生产部门,  WorkLineCode 产线编号, WorkLineName 产线, WorkTeamCode 班组编号, WorkTeamName 班组,";
            sql += " DayShiftCode 班别编号, DayShiftName 班别, CreateID, Creator 填报人,  CreateDate 填报时间, ModifyID, Modifier, ModifyDate,Customer 客户,ProductWidth 成品宽度,  ";
            sql += " LisuanThick 理算厚度,LisuanMeter 理算长度,卷径";
            sql += " FROM      bus_zincoutput where  ( VolumeCodeNew='" + 查询投入卷号1 + "' or VolumeCodeNew='" + 查询投入卷号2 + "')  order by OutputVolumeNew desc  ";
            DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
            if (tb != null)
            {
                uiDataGridView产出.AutoGenerateColumns = false;
                this.uiDataGridView产出.DataSource = tb;
                //this.uiDataGridView产出.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                this.uiDataGridView产出.Refresh();
                //产出卷必须连号,不连号不行。
                if (tb.Rows.Count > 0)
                {
                    实际投入卷号 = tb.Rows[0]["VolumeCodeNew"].ToString();
                    this.uiTextBox原料卷号.Text = 实际投入卷号;
                    for (int i = 0; i < this.uiDataGridView产出.Rows.Count; i++)
                    {
                        if (this.uiDataGridView产出.Rows[i].Cells["C质量等级"].Value.ToString() == "B")
                        {
                            this.uiDataGridView产出.Rows[i].Cells["C质量等级"].Style.BackColor = Color.FromArgb(255, 255, 128);
                        }
                        else if (this.uiDataGridView产出.Rows[i].Cells["C质量等级"].Value.ToString() == "S")
                        {
                            this.uiDataGridView产出.Rows[i].Cells["C质量等级"].Style.BackColor = Color.FromArgb(255, 0, 0);
                        }
                    }
                    if (tb.Rows.Count == 1)
                    {
                        卷的总重量 = pub.Todecimal(tb.Rows[0]["新重量"].ToString());
                        //只有一卷
                    }
                    else
                    {
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            卷的总重量 += pub.Todecimal(tb.Rows[i]["新重量"].ToString());
                            //if (this.uiTextBox前缀.Text + uiTextBox产出卷号.Text + (i + 1).ToString().PadLeft(2, '/') != tb.Rows[i]["新卷号"].ToString())
                            //{
                            //    MessageBox.Show("产出的卷号不连号请检查", "提示", MessageBoxButtons.OK);
                            //}
                        }
                    }

                    //显示是否关闭了。
                    sql = "select IsClosed from [Bus_ZincOriginal] where  VolumeCodeNew='" + 实际投入卷号 + "' )  ";
                    DataTable tb2 = pub.GetDataTable(pub.ConnectionString, sql);
                    if (tb2 != null)
                    {
                        if (tb2.Rows.Count > 0)
                        {
                            if (tb2.Rows[0]["IsClosed"].ToString() == "Y")
                            {
                                this.uiLabelIsClosed.Text = "已关闭";
                            }
                            else
                            {
                                this.uiLabelIsClosed.Text = "未关闭";
                            }
                        }
                    }
                }
                else
                {

                }
            }




        }

        private void Form镀锌报工维护_FormClosed(object sender, FormClosedEventArgs e)
        {
            删除自己的tempguid的数据(tempguid);
        }

        private void uiDataGridView产出_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && this.uiDataGridView产出.Rows.Count > 0)
            {
                if (this.uiDataGridView产出.Columns[e.ColumnIndex].Name == "C删除")
                {
                    if (!pub.Is镀锌报工原始卷被关闭(this.uiTextBox原料卷号.Text))
                    {
                        string 镀锌产出卷号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新卷号"].Value.ToString();
                        string 后续状态 = pub.Get镀锌产出卷的后续状态(镀锌产出卷号);
                        if (后续状态 != "未使用")
                        {
                            MessageBox.Show("这个卷状态有问题了", "提示", MessageBoxButtons.OK);
                            //显示卷信息到表格上
                            // this.uiDataGridView产出.Rows[e.RowIndex].Cells["C后续状态"].Value = 后续状态;
                            ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                            return;
                        }
                        else
                        {   //本人才能删除
                            string 填报人 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C填报人"].Value.ToString();
                            if (填报人 != pub.sys_user.UserTrueName)
                            {
                                MessageBox.Show("您不可以删除其他人员填报的数据", "提示", MessageBoxButtons.OK);
                                return;
                            }
                            if (MessageBox.Show("你要删除这个产出卷么?", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                //检查是否打印打标签了
                                if (pub.产出卷是否打印入库(镀锌产出卷号))
                                {
                                    MessageBox.Show("【"+ 镀锌产出卷号 + "】已经打印大标签入库，无法删除");
                                    return;
                                }

                                
                                string sql = "delete bus_zincoutput where OutputVolumeNew='" + 镀锌产出卷号 + "';";
                                sql += "delete from Bus_LablePrint where 生产批号 = '" + 镀锌产出卷号 + "';";
                                pub.ExecuteSql(pub.ConnectionString, sql, "删除产出的镀锌卷");
                                //原卷的状态还原
                                sql = "update Bus_ZincOriginal set IsClosed='N' , ColseUserId=NULL,ColseUserName=NULL,CloseDate=NULL where guid='" + 镀锌原卷guid + "'";
                                pub.ExecuteSql(pub.ConnectionString, sql, "单卷镀锌报工取消成功，自动开启原卷的状态");

                                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                            }

                        }
                    }
                    else
                    {
                        MessageBox.Show("已经关闭的投入卷不能删除产出卷信息", "提示", MessageBoxButtons.OK);
                        ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                        return;
                    }

                }
                else if (this.uiDataGridView产出.Columns[e.ColumnIndex].Name == "C打印小标签" && this.uiDataGridView产出.Rows[e.RowIndex].Cells["C去向"].Value.ToString() == "下线入库")
                {

                    Form小标签 form小标签 = new Form小标签();
                    form小标签.生产批号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新卷号"].Value.ToString();
                    form小标签.规格 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新规格"].Value.ToString();
                    form小标签.钢号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新材质"].Value.ToString();
                    form小标签.等级 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C质量等级"].Value.ToString();
                    form小标签.净重 = Math.Round(pub.Todecimal(this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新重量"].Value.ToString()), 0).ToString();
                    form小标签.工厂编号 = pub.全局工厂编号;
                    form小标签.来源种类 = "镀锌小标签";
                    form小标签.存货编号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C存货编号"].Value.ToString();
                    form小标签.品名 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C品名"].Value.ToString();
                    form小标签.表面处理 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C表面处理"].Value.ToString();
                    form小标签.表面状态 = "";
                    form小标签.执行标准 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C执行标准"].Value.ToString();
                    form小标签.长度 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新米数"].Value.ToString();
                    form小标签.生产日期 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C报工日期"].Value.ToString();
                    form小标签.班组 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C班组"].Value.ToString();
                    form小标签.产线名称 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C产线"].Value.ToString();
                    form小标签.卷径 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C卷径"].Value.ToString();
                    form小标签.包装 = this.uiComboBox包装.SelectedText;
                    form小标签.锌层 = this.uiTextBox锌层.Text;
                    form小标签.客户 = this.uiTextBox客户.Text;
                    //form小标签.保存的仓库 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C产线"].Value.ToString();
                    if (this.uiComboBox仓库.SelectedValue == null)
                    {
                        MessageBox.Show("请选择仓库");
                        return;
                    }
                    else
                    {
                        form小标签.仓库 = this.uiComboBox仓库.SelectedValue.ToString();
                    }
                    
                    form小标签.ShowDialog(this);
                    MessageBox.Show("打印结束");
                } else if (this.uiDataGridView产出.Columns[e.ColumnIndex].Name == "C打印小标签" && this.uiDataGridView产出.Rows[e.RowIndex].Cells["C去向"].Value.ToString() == "彩涂")
                {
                   
                    string 规格 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新规格"].Value.ToString();
                    int firstStarIndex = 规格.IndexOf('*'); // 获取第一个星号的索引
                    int secondStarIndex = 规格.IndexOf('*', firstStarIndex + 1); // 获取第二个星号的索引
                    string 打印规格 = "";
                    if (firstStarIndex != -1 && secondStarIndex != -1) // 确保找到了两个星号
                    {
                        int start = firstStarIndex + 1; // 提取文本的起始索引（第一个星号之后）
                        int length = secondStarIndex - start; // 提取的文本长度

                        打印规格 = 规格.Substring(start, length); // 提取文本
                    }
                    PrintUtil.打印("镀锌小标签", this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新卷号"].Value.ToString(),
                        this.uiDataGridView产出.Rows[e.RowIndex].Cells["C品名"].Value.ToString(),
                        this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新材质"].Value.ToString(),
                        this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新米数"].Value.ToString(),
                        打印规格,
                        this.uiDataGridView产出.Rows[e.RowIndex].Cells["C质量等级"].Value.ToString(),
                         "",
                         this.uiDataGridView产出.Rows[e.RowIndex].Cells["C表面处理"].Value.ToString(),
                         Math.Round(pub.Todecimal(this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新重量"].Value.ToString()), 0).ToString(),
                         this.uiDataGridView产出.Rows[e.RowIndex].Cells["C执行标准"].Value.ToString(),
                         this.uiDataGridView产出.Rows[e.RowIndex].Cells["C报工日期"].Value.ToString(),
                         this.uiDataGridView产出.Rows[e.RowIndex].Cells["C班组"].Value.ToString(), this.uiDataGridView产出.Rows[e.RowIndex].Cells["C去向"].Value.ToString());
                    MessageBox.Show("打印结束");
                }
            }
        }

        private void uiButton关闭_Click(object sender, EventArgs e)
        {
            string sql;
            //产出卷必须连号
            sql = "SELECT   OutputGuid, guid, Row, OutputVolumeNew 新卷号, OutputSize 新规格, OutputThick 新厚度, OutputWidth 新宽度, OutputMaterial 新材质, OutputWeight 新重量, OutputQualityGrade 质量等级, OutputQualityInformation 质量信息, OutputEndStatus 后续状态, OutputNext 去向,";
            sql += " PrintTimes 打印次数, DepartCode 部门编号, DepartName 生产部门,  WorkLineCode 产线编号, WorkLineName 产线, WorkTeamCode 班组编号, WorkTeamName 班组, DayShiftCode 班别编号, DayShiftName 班别, CreateID, Creator 填报人,  CreateDate 填报时间, ModifyID, Modifier, ModifyDate ";
            sql += " FROM      Bus_ZincOutput where guid='" + 镀锌原卷guid + "' order by OutputVolumeNew ";
            DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
            if (tb != null)
            {
                uiDataGridView产出.AutoGenerateColumns = false;
                this.uiDataGridView产出.DataSource = tb;
                //this.uiDataGridView产出.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                this.uiDataGridView产出.Refresh();
                //产出卷必须连号,不连号不行。
                if (tb.Rows.Count > 0)
                {
                    if (tb.Rows.Count == 1)
                    {
                        //只有一卷
                    }
                    else
                    {
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            if (this.uiTextBox前缀.Text + uiTextBox产出卷号.Text + (i + 1).ToString().PadLeft(2, '/') != tb.Rows[i]["新卷号"].ToString())
                            {
                                MessageBox.Show("产出的卷号不连号请检查", "提示", MessageBoxButtons.OK);
                                return;
                            }
                        }
                    }

                }
            }


            if (MessageBox.Show("你要关闭这个投入卷么?", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                sql = "update Bus_ZincOriginal set IsClosed='Y' , ColseUserId='" + pub.sys_user.User_Id + "',ColseUserName='" + pub.sys_user.UserTrueName + "',CloseDate=getdate() where guid='" + 镀锌原卷guid + "'";
                pub.ExecuteSql(pub.ConnectionString, sql, "镀锌手动关闭原卷的状态");
                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
            }
        }

        private void uiTextBox原料卷号_KeyPress(object sender, KeyPressEventArgs e)
        {
            //if (e.KeyChar == 13)
            //{
            //    Bus_HardOriginal bus_hardoriginal = pub.Get镀锌投入信息(pub.全局工厂编号, this.uiTextBox原料卷号.Text);
            //        if (bus_hardoriginal!=null)
            //        {
            //        镀锌原卷guid = bus_hardoriginal.guid.ToString();
            //        this.uiTextBox产出卷号.Text = pub.去掉前缀(this.uiTextBox原料卷号.Text);//不含前缀，不含后面的串号
            //        uiTextBox规格型号1.Text = bus_hardoriginal.OriginalSize;
            //        string 厚度 = "";
            //        string 宽度 = "";
            //        string 虚拟值 = "";
            //        pub.FromSize(uiTextBox规格型号1.Text, out 厚度, out 宽度, out 虚拟值);
            //        this.uiTextBox厚度1.Text = 厚度;
            //        this.uiTextBox宽度1.Text = 宽度;
            //        this.uiTextBox新厚度.Text = 厚度;
            //        this.uiTextBox新宽度.Text = 宽度;
            //        this.uiTextBox卷重量1.Text = bus_hardoriginal.OriginalWeight.ToString();
            //        this.uiTextBox材质1.Text = bus_hardoriginal.OriginalMaterial;
            //        this.uiTextBox米数.Text = bus_hardoriginal.OriginalMeter.ToString();
            //        this.uiComboBox新材质.Text = this.uiTextBox材质1.Text;
            //        this.uiTextBox计量单位1.Text = "Kg";
            //        ListHardOutput(镀锌原卷guid);
            //        塞入自己的tempguid的数据(tempguid, bus_hardoriginal.OriginalVolumeNew);


            //}








        }



        private void uiLabel18_Click(object sender, EventArgs e)
        {

        }

        private void uiButton搜索已生产卷_Click(object sender, EventArgs e)
        {
            List已生产卷();
        }

        private void List已生产卷()
        {
            用来保存的原卷号 = "";
            Bus_ZincOriginal bus_zincoriginal = pub.Get镀锌投入信息(pub.全局工厂编号, this.uiTextBox原料卷号.Text, out 用来保存的原卷号);
            if (bus_zincoriginal != null)
            {
                镀锌原卷guid = bus_zincoriginal.guid.ToString();
                this.uiTextBox原料卷号.Text = 用来保存的原卷号;
                this.uiTextBox产出卷号.Text = pub.去掉前缀(this.uiTextBox原料卷号.Text);//不含前缀，不含后面的串号
                uiTextBox规格型号1.Text = bus_zincoriginal.OriginalSize;
                string 厚度 = "";
                string 宽度 = "";
                string 虚拟值 = "";
                numericUpDown1.Value = 1;
                pub.FromSize(uiTextBox规格型号1.Text, out 厚度, out 宽度, out 虚拟值);
                this.uiTextBox厚度1.Text = 厚度;
                this.uiTextBox宽度1.Text = 宽度;
                this.uiTextBox新厚度.Text = 厚度;
                //this.uiTextBox新宽度.Text = "";
                this.uiTextBox新米数.Text = "";
                Bus_PlanZinc bus_PlanZinc = pub.Get镀锌计划(用来保存的原卷号);
                if (bus_PlanZinc != null)
                {
                    string 成品规格 = bus_PlanZinc.ProductSize;
                    string 成品厚度;
                    string 成品宽度;
                    pub.FromSize(成品规格, out 成品厚度, out 成品宽度, out 虚拟值);
                    uiTextBox成品宽度.Text = 成品宽度;
                    uiTextBox新厚度.Text = 成品厚度;
                    if (bus_PlanZinc != null && !string.IsNullOrEmpty(bus_PlanZinc.ZincThick))
                    {
                        this.uiTextBox锌层.Text = bus_PlanZinc.ZincThick;
                    }
                    else
                    {
                        this.uiTextBox锌层.Text = "普通";
                    }
                }
                else
                {
                    uiTextBox成品宽度.Text = "";

                }

                //查询客户名称
                string sqlCustomer = @"select Customer from Bus_PlanZinc
                                       where WorkShopCode='3001' 
                                       and (VolumeCodeNew='" + this.uiTextBox原料卷号.Text + "')";
                DataTable dtCustomer = pub.GetDataTable(pub.ConnectionString, sqlCustomer);
                if (dtCustomer != null && dtCustomer.Rows.Count > 0)
                {
                    this.uiTextBox客户.Text = dtCustomer.Rows[0][0].ToString();
                }
                else
                {
                    this.uiTextBox客户.Text = bus_zincoriginal.Customer;
                }

                
                if (this.uiTextBox客户.Text == "")
                {
                    if (用来保存的原卷号.Contains("PHY"))
                    {
                        Bus_HardOutput bus_HardOutput = pub.Get轧硬产出卷信息(用来保存的原卷号);
                        if (bus_HardOutput != null)
                        {
                            this.uiTextBox客户.Text = bus_HardOutput.Customer;
                        }
                    }
                    else
                    {
                        Bus_PicklingOutput bus_PicklingOutput = pub.Get酸洗产出卷信息(用来保存的原卷号);
                        {
                            this.uiTextBox客户.Text = bus_PicklingOutput.Customer;
                        }

                    }


                }
                this.uiTextBox卷重量1.Text = bus_zincoriginal.OriginalWeight.ToString();
                uiTextBox新重量.Text = "";
                if (bus_zincoriginal.OriginalAddress != null)
                {
                    this.uiTextBox产地1.Text = bus_zincoriginal.OriginalAddress.ToString();
                }
                this.uiTextBox材质1.Text = bus_zincoriginal.OriginalMaterial;
                this.uiTextBox米数.Text = bus_zincoriginal.OriginalMeter.ToString();
                //this.uiComboBox新材质.Text = this.uiTextBox材质1.Text;
                this.uiTextBox计量单位1.Text = "Kg";

                if (bus_PlanZinc != null && !string.IsNullOrEmpty(bus_PlanZinc.NextWorkType))
                {
                    this.uiComboBox去向.SelectedValue = bus_PlanZinc.NextWorkType;
                }

                ListOutput(this.uiTextBox原料卷号.Text.Trim().Replace("--", ""));
                塞入自己的tempguid的数据(tempguid, bus_zincoriginal.OriginalVolumeNew);
            }
            else
            {
                MessageBox.Show("没有投入的卷信息，请先选择投入卷 " + this.uiTextBox原料卷号.Text, "提示", MessageBoxButtons.OK);
                return;
            }
        }
        private void uiButtonClearAll_Click(object sender, EventArgs e)
        {
            CleallAll();
        }
        private void uiComboBox去向_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.uiComboBox去向.SelectedText == "下线入库")
            {
                this.uiLabel表面处理.Visible = true;
                this.uiComboBox执行标准.Visible = true;
                this.uiLabel执行标准.Visible = true;
                this.uiComboBox表面处理.Visible = true;
                this.uiLabel品名.Visible = true;
                this.uiComboBox品名.Visible = true;
                //this.uiLabel锌层.Visible = true;
                //this.uiTextBox锌层.Visible = true;
                this.uiComboBox包装.Visible = true;
                this.uiLabel包装.Visible = true;
                //this.uiTextBox新规格.Text = this.uiTextBox查询成品规格.Text;
                pub.List品名(this.uiComboBox品名, FormWorkType, this.uiComboBox质量等级.SelectedText);
            }
            else
            {
                this.uiLabel表面处理.Visible = false;
                this.uiComboBox执行标准.Visible = false;
                this.uiLabel执行标准.Visible = false;
                this.uiComboBox表面处理.Visible = false;
                this.uiLabel品名.Visible = false;
                this.uiComboBox品名.Visible = false;
                //this.uiLabel锌层.Visible = false;
                //this.uiTextBox锌层.Visible = false;
                this.uiComboBox包装.Visible = false;
                this.uiLabel包装.Visible = false;
            }
        }

        private void uiComboBox质量等级_SelectedIndexChanged(object sender, EventArgs e)
        {
            pub.List品名(this.uiComboBox品名, FormWorkType, this.uiComboBox质量等级.SelectedText);
        }


        private void uiTextBox新米数_TextChanged(object sender, EventArgs e)
        {
            刷新理算厚度();
            刷新理算米数();
            decimal 面积 = pub.计算成品面积(uiTextBox新米数.Text.ToString(), uiTextBox成品宽度.Text.ToString());
            uiTextBox面积.Text = 面积.ToString();
        }

        private void 刷新理算厚度()
        {
            double 手填重量;

            手填重量 = pub.Todouble(this.uiTextBox新重量.Text);
            double 手填宽度;
            手填宽度 = pub.Todouble(this.uiTextBox新宽度.Text);
            //double 手填厚度;
            //手填厚度 = pub.Todouble(this.uiTextBox新宽度.Text);
            double 手填米数;
            手填米数 = pub.Todouble(this.uiTextBox新米数.Text);
            if (手填重量 > 0 && 手填宽度 > 0 && 手填米数 > 0)
            {
                this.uiTextBox理算厚度.Text = Math.Round((手填重量 / (手填宽度 / 1000) / 手填米数 / 7.85), 4).ToString();
            }
            else
            {
                this.uiTextBox理算厚度.Text = "";
            }
        }

        private void uiTextBox新重量_TextChanged(object sender, EventArgs e)
        {
            刷新理算米数();
            刷新理算厚度();
        }

        private void uiButton投入查询_Click(object sender, EventArgs e)
        {
            ListData();
        }

        private void ListData()
        {

            string sql;
            sql = @"SELECT row_number() over(order by  时间,卷号 ) 序号,   工厂编号, 时间, 卷号, 规格型号, 材质, 重量, 米数,产地, 质量等级, 质量信息, 去向, WorkShopGuid, 计划产出规格, 成品规格, 
                计划去向,  客户,分卷要求   from   View_已酸洗轧硬未镀锌 where 1=1  ";
            sql += " and 工厂编号='" + pub.全局工厂编号 + "'   ";

            if (this.uiTextBox查询材质.Text != "")
            {
                sql += " and 材质 ='" + this.uiTextBox查询材质.Text.Trim().Replace("--", "") + "'";
            }
            if (this.uiTextBox查询规格型号.Text.Trim() != "")
            {
                sql += " and 规格型号 ='" + this.uiTextBox查询规格型号.Text.Trim().Replace("--", "") + "'";
            }

            if (this.uiTextBox查询成品规格.Text.Trim() != "")
            {
                sql += " and 成品规格 ='" + this.uiTextBox查询成品规格.Text.Trim().Replace("--", "") + "'";
            }

            if (this.uiTextBox查询卷号.Text.Trim() != "")
            {
                sql += " and 卷号 like '%" + this.uiTextBox查询卷号.Text.Trim().Replace("--", "") + "%'";
            }
            if (this.uiTextBox查询客户.Text.Trim() != "")
            {
                sql += " and 客户 = '" + this.uiTextBox查询客户.Text.Trim().Replace("--", "") + "'";
            }
            DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
            if (tb.Rows.Count > 0)
            {
                //二次处理一下
                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    if (tb.Rows[i]["成品规格"].ToString() == "")
                    {
                        string 卷号 = tb.Rows[i]["卷号"].ToString();
                        DataTable dt = pub.Get镀锌成品规格(卷号);
                        if (dt != null && dt.Rows.Count == 1)
                        {
                            tb.Rows[i]["成品规格"] = dt.Rows[0]["ProductSize"].ToString();
                            tb.Rows[i]["计划产出规格"] = dt.Rows[0]["OutputSize"].ToString();
                            tb.Rows[i]["计划去向"] = dt.Rows[0]["NextWorkType"].ToString();
                            tb.Rows[i]["分卷要求"] = dt.Rows[0]["SplitDesc"].ToString();

                        }
                        else if (dt != null && dt.Rows.Count > 1)
                        {
                            MessageBox.Show($"{卷号}的镀锌计划重复，查到{dt?.Rows.Count}条计划");
                        }
                    }
                }

                this.uiDataGridView可用.AutoGenerateColumns = false;
                //this.uiDataGridView可用.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                this.uiDataGridView可用.DataSource = tb;
                this.uiDataGridView可用.Refresh();
            }
            else
            {
                this.uiDataGridView可用.DataSource = null;
                this.uiDataGridView可用.Refresh();
                MessageBox.Show("没有已酸洗轧硬未镀锌的卷可以选择", "提示", MessageBoxButtons.OK);
                return;
            }
        }


        private void uiLabel13_Click(object sender, EventArgs e)
        {

        }

        private void uiTextBox规格型号1_TextChanged(object sender, EventArgs e)
        {

        }

        private void uiDataGridView可用_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && this.uiDataGridView可用.Columns[e.ColumnIndex].Name == "D选择")
            {
                this.uiTextBox原料卷号.Text = this.uiDataGridView可用.Rows[e.RowIndex].Cells["D卷号"].Value.ToString();
                镀锌原卷guid = pub.Get镀锌报工guid(this.uiTextBox原料卷号.Text);
                List已生产卷();
            }
        }

        private void uiButton产出查询_Click(object sender, EventArgs e)
        {
            DataTable tb = ListOutPutData();
            uiDataGridView1.AutoGenerateColumns = false;
            this.uiDataGridView1.DataSource = tb;
            //this.uiDataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            this.uiDataGridView1.Refresh();
            for (int i = 0; i < this.uiDataGridView1.Rows.Count; i++)
            {
                if (this.uiDataGridView1.Rows[i].Cells["E产出等级"].Value.ToString() == "B")
                {
                    this.uiDataGridView1.Rows[i].Cells["E产出等级"].Style.BackColor = Color.FromArgb(255, 255, 128);
                }
                else if (this.uiDataGridView1.Rows[i].Cells["E产出等级"].Value.ToString() == "S")
                {
                    this.uiDataGridView1.Rows[i].Cells["E产出等级"].Style.BackColor = Color.FromArgb(255, 0, 0);
                }
            }
        }

        private DataTable ListOutPutData()
        {
            string sql;
            sql = "SELECT   row_number() over(order by 投入卷号) 序号, 投入卷号, 投入规格, 投入重量, 投入材质, 生产日期, 产出卷号, 产出规格, 产出材质, ";
            sql += " 产出重量, 产出等级, 去向, 产线名称, ";
            sql += " 班组名称, 班别,客户,锌层,长度 FROM      View_镀锌投入产出明细表 ";
            sql += " where 1=1  and 生产日期 >='" + this.uiDatePicker开始日期.Value.ToString() + "'";
            sql += " and 生产日期 < '" + this.uiDatePicker结束日期.Value.AddDays(1) + "'";

            if (this.uiComboBox查询产线.SelectedText != "全部")
            {
                sql += " and 产线名称='" + this.uiComboBox查询产线.SelectedText + "' ";
            }
            if (this.uiComboBox查询班组.SelectedText != "全部")
            {
                sql += " and 班组名称='" + this.uiComboBox查询班组.SelectedText + "' ";
            }
            if (this.uiTextBox投入卷号包含.Text != "")
            {
                sql += " and 投入卷号 like '%" + this.uiTextBox投入卷号包含.Text.Trim().Replace("--", "") + "%' ";
            }
            if (this.uiTextBox产出卷号包含.Text != "")
            {
                sql += " and 产出卷号 like '%" + this.uiTextBox产出卷号包含.Text.Trim().Replace("--", "") + "%' ";
            }

            DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
            return tb;
        }

        private void uiButton导出_Click(object sender, EventArgs e)
        {
            string path;
            DataTable tb = ListOutPutData();
            saveFileDialog1.Filter = "Excel文件 (*.XLSX)|*.XLSX";
            if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
            {
                path = this.saveFileDialog1.FileName;
                if (!File.Exists(path))
                {
                    MiniExcel.SaveAs(path, tb, true, "sheet1", ExcelType.XLSX);
                }
                else
                {
                    MessageBox.Show("文件已经存在,请重试!", "提示", MessageBoxButtons.OK);
                    return;
                }

            }
        }

        private void uiDataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            开始行 = e.RowIndex;
        }

        private void uiDataGridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {

            decimal 总投入重量 = 0;
            decimal 投入重量 = 0;
            decimal 总产出重量 = 0;

            string guid = Guid.NewGuid().ToString();
            int 总卷数 = 0;
            结束行 = e.RowIndex;
            if (开始行 >= 0 && 结束行 > 0)
            {
                if (开始行 > 结束行)
                {
                    int k = 开始行;
                    开始行 = 结束行;
                    结束行 = k;
                }
                string sql = "delete Temp_投入汇总表 where guid='" + guid + "'";
                pub.ExecuteSql(pub.ConnectionString, sql, "delete Temp_投入汇总表 ");
                for (int i = 开始行; i <= 结束行; i++)
                {
                    投入重量 = pub.Todecimal(this.uiDataGridView1.Rows[i].Cells["E投入重量"].Value.ToString());
                    string 投入卷号 = this.uiDataGridView1.Rows[i].Cells["E投入卷号"].Value.ToString();
                    sql = " insert into Temp_投入汇总表 (guid, 卷号, 投入重量) ";
                    sql += " values('" + guid + "','" + 投入卷号 + "','" + 投入重量 + "')";
                    pub.ExecuteSql(pub.ConnectionString, sql, "insert into Temp_投入汇总表 ");

                    总产出重量 += pub.Todecimal(this.uiDataGridView1.Rows[i].Cells["E产出重量"].Value.ToString());
                    总卷数++;
                }
                sql = "select  isnull(  sum(t.投入重量),0)  from  (select distinct 卷号, 投入重量 from Temp_投入汇总表 where guid='" + guid + "' ) t ";
                DataTable tb = pub.GetDataTable(pub.ConnectionString, sql);
                if (tb.Rows.Count > 0)
                {
                    总投入重量 = pub.Todecimal(tb.Rows[0][0].ToString());
                }
                else
                {
                    总投入重量 = 0;
                }
                sql = "delete Temp_投入汇总表 where guid='" + guid + "'";
                pub.ExecuteSql(pub.ConnectionString, sql, "delete Temp_投入汇总表 ");

                if (总投入重量 != 0)
                {
                    this.uiTextBox产出率.Text = Math.Round((pub.Todecimal(总产出重量 / 总投入重量) * 100), 2).ToString();
                }
                else
                {
                    this.uiTextBox产出率.Text = "";
                }
                this.uiTextBox卷数.Text = 总卷数.ToString();
                this.uiTextBox投入重量合计.Text = Math.Round(总投入重量, 3).ToString();
                this.uiTextBox产出重量合计.Text = Math.Round(总产出重量, 3).ToString();
            }
        }

        private void uiDataGridView产出_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                DataGridViewRow dgbr = this.uiDataGridView产出.Rows[e.RowIndex];


                string 规格 = dgbr.Cells["C新规格"].Value.ToString();
                string 厚度;

                string 宽度;
                string 虚拟值;
                pub.FromSize(规格, out 厚度, out 宽度, out 虚拟值);
                string 报工日期 = dgbr.Cells["C报工日期"].Value.ToString();
                string 填报人 = dgbr.Cells["C填报人"].Value.ToString();
                string 镀锌产出卷号 = this.uiDataGridView产出.Rows[e.RowIndex].Cells["C新卷号"].Value.ToString();
                decimal 重量 = pub.Todecimal(dgbr.Cells["C新重量"].Value.ToString());
                string 材质 = dgbr.Cells["C新材质"].Value.ToString();
                string 质量等级 = dgbr.Cells["C质量等级"].Value.ToString();
                string 去向 = dgbr.Cells["C去向"].Value.ToString();
                string 客户 = dgbr.Cells["C客户"].Value.ToString();
                string 质量信息 = dgbr.Cells["C质量信息"].Value.ToString();
                string 存货编号 = dgbr.Cells["C存货编号"].Value.ToString();
                string 品名 = dgbr.Cells["C品名"].Value.ToString();
                //修改班组班别 修改的班组名称要在数据库里存在
                string 班组名称 = dgbr.Cells["C班别"].Value.ToString();
                string 班组编号 = "";
                string sqlDayShift;
                sqlDayShift = "SELECT   guid, WorkShopGuid, WorkShopCode, DayShiftCode, DayShiftName, AuditDate, AuditStatus, AuditId, Auditor, Remark,  CreateID, Creator, CreateDate, ModifyID, Modifier, ModifyDate FROM      Dic_DayShift";
                sqlDayShift += " where WorkShopCode='" + pub.全局工厂编号 + "' and DayShiftName = '"+ 班组名称 + "'";
                DataTable tbDayShift = pub.GetDataTable(pub.ConnectionString, sqlDayShift);
                if (tbDayShift != null && tbDayShift.Rows.Count > 0)
                {
                    班组编号 = tbDayShift.Rows[0]["DayShiftCode"].ToString();
                }
                else
                {
                    MessageBox.Show("输入的班组不存在，请重新输入，班组有【白班，夜班，中班】", "提示");
                    return;
                }


                //string 表面处理 = dgbr.Cells["C表面处理"].Value.ToString();
                string 后续状态 = pub.Get镀锌产出卷的后续状态(镀锌产出卷号);
                if (后续状态 != "未使用")
                {
                    MessageBox.Show("这个卷状态:" + 后续状态, "提示", MessageBoxButtons.OK);
                    //显示卷信息到表格上
                    // this.uiDataGridView产出.Rows[e.RowIndex].Cells["C后续状态"].Value = 后续状态;
                    ListOutput(this.uiTextBox原料卷号.Text);
                    return;
                }
                else
                {   //本人才能删除

                    if (填报人 != pub.sys_user.UserTrueName && pub.sys_user.UserTrueName != "超级管理员")
                    {
                        MessageBox.Show("您不可以修改其他人员填报的数据", "提示", MessageBoxButtons.OK);
                        return;
                    }
                    if (MessageBox.Show("你要修改这个产出卷么？数据需要填正确哦！", "询问", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        string sql = "update Bus_ZincOutput set  " +
                            "OutputDate='" + 报工日期 + "'," +
                            "OutputSize='" + 规格 + "'," +
                            "OutputThick='" + 厚度 + "'," +
                            "OutputWidth='" + 宽度 + "'," +
                            "OutputQualityGrade='" + 质量等级 + "'," +
                            "OutputMaterial='" + 材质 + "'," +
                            "OutputNext='" + 去向 + "'," +
                            "OutputWeight='" + 重量 + "'," +
                            "Customer='" + 客户 + "'," +
                            "OutputQualityInformation='" + 质量信息 + "'," +
                            "InventoryCode='" + 存货编号 + "'," +
                            "InventoryName='" + 品名 + "'," +
                            "DayShiftCode='" + 班组编号 + "'," +
                            "DayShiftName='" + 班组名称 + "'" +
                            //"FaceDone='" + 表面处理 + "'" +
                            "where OutputVolumeNew='" + 镀锌产出卷号 + "'";
                        if (pub.ExecuteSql(pub.ConnectionString, sql, "修改产出的镀锌卷") > 0)
                        {
                            MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK);
                        }
                    }

                }

            }
        }

        private void uiTextBox成品宽度_TextChanged(object sender, EventArgs e)
        {
            decimal 面积 = pub.计算成品面积(uiTextBox新米数.Text.ToString(), uiTextBox成品宽度.Text.ToString());
            uiTextBox面积.Text = 面积.ToString();
        }
    }
}
